1. Field of the Invention
The present invention relates to an encoder which compresses handwriting stroke information, and a decoder for decoding the data encoded by the encoder. More particularly, the present invention relates to an encoder capable of being used with a handwritten data processing terminal.
2. Description of the Related Art
A zone encoding scheme (refer to JT-T150 recommendations) is now known as an encoding scheme for compressing handwriting stroke information by sampling it.
Handwritten data is characterized such that a sampling range becomes comparatively narrow when letters are written, and in spite of an increase in angular variations the range of one handwriting stroke becomes larger when a map or drawing is drawn.
The zone encoding scheme is a prediction encoding method utilizing these characteristics of the handwritten data.
More specifically, as provided in FIG. 1, a coordinate plane is set by defining the point sampled at some point in time as the origin (0, 0) of the coordinate system according to the zone encoding scheme. The coordinate plane is divided into four quadrants; namely, .theta.=1-4. Each of the quadrants is numbered. Presume that the origin and the X-axis and Y-axis in the positive direction with respect to the origin belong to the first quadrant; the Y-axis in the negative direction with respect to the origin belongs to the fourth quadrant; and the X-axis in the negative direction pertains to the second quadrant.
Each quadrant is further divided into zones as designated by a solid line provided in FIG. 2. Each zone is assigned a zone number, as provided in FIG. 2. Each of the zones is further divided into inside-of-zone coordinates (or inside-of-zone addresses) as designated by a broken line provided in FIG. 2. As illustrated in FIG. 2, a zone area (i.e., the quadrant) is usually divided into 10 zones and measures 16.times.16 pixels.
With this arrangement, certain sampled coordinates can be formed into coordinate information comprised of only three items of information; namely, the difference between a quadrant number of the sampled coordinates and a quadrant number of other coordinates sampled immediately before the sampled coordinates; the difference between a zone number of the sampled coordinates and a zone number of the coordinates sampled immediately before the sampled coordinates; and an address of the sampled coordinates within their quadrant number (an inside-of-zone address). Both a quadrant number and a zone number of coordinates of a stroke starting point (i.e., first sampled coordinates) are set to one. The inside-of-zone address designates the position of sampled coordinates in a certain zone and is expressed by the combination of an address in the X-axis direction and an address in the Y-axis direction.
For instance, provided that the second sampled coordinates have a quadrant number 3 and a zone number 4, the quadrant number difference between the quadrant number of the second sampled coordinates and the quadrant number of the first sampled coordinates is obtained as follows: 3-1=2. Similarly, the zone number difference between the zone number of the second sampled coordinates and the zone number of the first sampled coordinates is obtained as follows: 4-1=3.
To compress the amount of the data obtained by direct encoding of the sampled coordinates, the sampled coordinates are encoded by the combination of quadrant number and zone number differences. More specifically, the information is encoded with reference to a zone code table provided in FIG. 3. The zone code table defines the relationship between zone codes and the combination of quadrant number and zone number differences. In this zone code table, fewer bits are allocated to the zone code numbers having higher frequencies of occurrence by utilization of the characteristics of the handwritten data. If the sampled coordinates to be sampled subsequently do not exist in the zone area, or if the combination of the differences of the quadrant and zone numbers between the sampled coordinates and the coordinates to be sampled subsequently, are not included in the combinations provided in FIG. 3, the absolute values of the coordinates to be sampled subsequently, are directly encoded. Here, the absolute values of the stroke starting point are directly encoded without calculating a quadrant difference and a zone difference with regard to the coordinates of the stroke starting point.
According to the zone encoding method, if the difference between certain sampled coordinates (Xi-1, Yi-1) and coordinates (Xi, Yi) to be sampled subsequently is (0, 0), the coordinates for which a determination is made as to whether or not they will be decoded, will not be encoded. Further, the coordinates sampled after the certain coordinates are not required to be encoded if the differences between certain sampled coordinates and coordinates sampled after these coordinates, with regard to their X and Y components are respectively 1 or less. More specifically, if the differences between certain sampled coordinates and coordinates sampled after these coordinates are .vertline.Xi-Xi-1).vertline..ltoreq.1 and .vertline.Yi-(Yi-1).vertline..ltoreq.1, the coordinates sampled after the certain coordinates are not required to be encoded.
The zone encoding scheme will be described more specifically, provided that a drawing is handwritten as illustrated in FIG. 5, and coordinates I=1-7 are sampled.
The first sampled coordinates I=1 (3, 5) are encoded directly and are represented as 9 bits (000000011000000101).
Next, the differences between the first sampled coordinates (5, 6) and the second sampled coordinates I=2 (3, 5); namely, a quadrant number difference and a zone number difference, are calculated. Given that the coordinates (3, 5) are the relative origin, the coordinates (5, 6) are redefined as diagonally slanted coordinates (2, 1) on the zone area provided in FIG. 2. The second sampled coordinates are located in the first quadrant with respect to the relative origin. In other words, the quadrant number of the second sampled coordinates is one, and its zone number is two. Therefore, the differences between the second sampled coordinates having quadrant number 1 and zone number 2 and the first sampled coordinates having quadrant number 1 and zone number 1, become (0, 1).
The combination of the quadrant number difference and the zone number difference; namely, (0, 1), is applied to the zone code table (see FIG. 3), whereby a zone code (1011) is obtained.
As is evident from FIG. 2, the inside-of-zone address of the second sampled coordinates is defined as 0 in the X-axis direction and 1 in the Y-axis direction; namely, (0 1). This inside-of-address is added to the previously obtained zone code (1011), whereby the second sampled coordinates (5, 6) is encoded into (1011 01).
As in the case of the second sampled coordinates, the third sampled coordinates (7, 7) are encoded with respect to the relative point; namely, the second coordinates sampled immediately before the third coordinates, by use of information about the quadrant number difference, the zone number difference, and the inside-of-zone address.
More specifically, coordinates derived from the differences between the third sampled coordinates (7, 7) and the second sampled coordinates (5, 6), are (2, 1). The third sampled coordinates are located in the first quadrant with respect to the relative origin; namely, the quadrant number of the third sampled coordinates is one. The zone number 2 of the third sampled coordinates is two. Therefore, the third sampled coordinates has quadrant number 1 and zone number 2. The differences between the second sampled coordinates and the third sampled coordinates with regard to the quadrant number and the zone number are 0 and 0, respectively.
"PLI" provided in the zone code table (see FIG. 3) is a symbol denoting that a pen is lifted up. "EFZ" is a symbol denoting that the pen is located out of the zone area. As illustrated in FIG. 2, ten zones are provided in the zone area according to the zone encoding scheme. If the sampled coordinates to be encoded do not belong to any one of these zones, they will be encoded by adding the absolute values of the sampled coordinates to the code (000010) of the EFZ.
According to the above-described zone encoding scheme, the quadrant and zone numbers of coordinates to be sampled subsequently, are obtained while the coordinates sampled immediately before the sampled coordinates are used as the origin. Therefore, as the distance between the two sampled coordinates increases, the differences between them becomes greater. As a result, the number of bits which are allocated when coordinates are encoded, will become greater, thereby resulting in a greater amount of encoded data.
Further, if a sampling period becomes longer, the distance between two sampled coordinates will become greater, and hence the amount of encoded data will become greater accordingly.
Particularly, if the distance between two sampled coordinates becomes longer, the secondly-sampled coordinates are determined to be located out of the zone area and are encoded as such. Eventually, the length of encoded resultant data is increased. Such a greater amount of encoded data results in an increase in communications and storage costs.
Further, if a handwriting large width of a stroke path causes draw areas (or pen areas) of adjacent sampled coordinates to overlap, it results in encoding of undesired sampled coordinates, causing encoded data to increase. Provided that it is possible to select the thickness of a line to be displayed on a display screen from a plurality of thicknesses, if a wide line is selected, the draw areas of the sampled coordinates may overlap. In this case, it is not necessary to decode encoded data of these sampled coordinates.
In either of the cases; e.g., where a sampling rate is slow, and where a handwriting stroke rate is fast, the differences between two sampled coordinates will become large in many situations. Particularly, if the line width is large, large-sized letters or drawings will be drawn often. Eventually, a handwriting stroke rate also increases, and the differences between two sampled coordinates increases. In such a case, the sampled coordinates are often determined to be out of the zone area, and the amount of resultantly encoded data of these sampled coordinates increases. More specifically, if the differences between two sampled coordinates are large, it is determined that the secondly-sampled coordinates will not fall within the zone area provided in FIG. 2. As a result, the secondly-sampled coordinates are determined as to be outside of the zone area. If the size of the zone area is increased to 16.times.16 pixels or more, if 10 or more zones are provided in the zone area, or if the secondly-sampled coordinates are located in the zone area, in many cases, the secondly-sampled coordinates still fail to correspond to any one of the code numbers provided in the zone code table 3. Therefore, the absolute values of the coordinates are directly encoded, thereby resulting in lengthy encoded data.